<template>
	<svg xmlns="http://www.w3.org/2000/svg" version="1.1" style="float: right; width:72px; height:68px; margin:0px;">
	  <circle cx="35" cy="35" r="30" stroke="#bbb"
	  stroke-width="2" fill="transparent">
		
	  </circle>
	  <text x="35" y="37" width="60" height="60" fill="red" style="font-size: 28px; dominant-baseline:middle;text-anchor:middle;">{{second}}</text>
	</svg>
</template>

<script>
	export default{
		data(){
			return {
				second: this.seconds,
				intervalId:0,
				currentUrl:'',
			}
		},
		
		props:['seconds', 'url', 'title'],
		
		created(){
			if(isNaN( this.second))
				this.second = 60;
				
			this.currentUrl = this.$route.path;
				
			this.intervalId = window.setInterval(()=>{
				this.second--;
				if(this.second == 5 && !this.url ){
					//this.toast( this.title + '即将超时退出.',5000)
				}else if(this.second <= 0){ 
					this.send({name:'Abort', remark: this.title + '超时退出体检', route:'/home', currentRoute:this.currentUrl});
					this.$router.push(this.url || '/home');
				}
			},1000)
		},
		
		beforeDestroy(){
			if(this.intervalId != 0){
				this.toast( '',1)
				window.clearTimeout(this.intervalId)
			}
		}
	}
</script>

<style>
</style>
